package com.mycompany.goodsys.core.AddGood;

import com.mycompany.goodsys.basecom.Observer.EventName;
import com.mycompany.goodsys.basecom.Observer.EventSystem;
import com.mycompany.goodsys.core.AppEntity.AppEntity;
import com.mycompany.goodsys.core.AppEntity.AppObj;
import com.mycompany.goodsys.core.AppStateCtrl;

public class AddGoodCtrl {
    public static void Update() {
        AddGoodView.Update();
    }

    private static void BindEvent(){
        EventSystem.BindEvent(EventName.EnterKey,(Object[] objs)->{
            String key = objs[0].toString();
            if(key.equals("back")){
                AppStateCtrl.ChangeState(AppStateCtrl.AppState.MainView);
            }else if(key.length() > 0){
                AddGoodData.SetInfo(key);
            }
        });
    }
    public static void Init() {
        AddGoodData.Init();
        AddGoodView.Init();
        BindEvent();
    }

    public static void Out() {
        EventSystem.RemoveEvent(EventName.EnterKey);
    }
}
